package mason.dp.observerjdk;

import java.util.Observable;

/**
 * 继承java.util.Observable来实现被观察者
 * @author MasonAir
 *
 */
public class WeatherData extends Observable {
	private float temperature;
	private float humidity;
	private float pressure;

	public WeatherData() {
	};

	public float getTemperature() {
		return temperature;
	}

	public void setTemperature(float temperature) {
		this.temperature = temperature;
	}

	public float getHumidity() {
		return humidity;
	}

	public void setHumidity(float humidity) {
		this.humidity = humidity;
	}

	public float getPressure() {
		return pressure;
	}

	public void setPressure(float pressure) {
		this.pressure = pressure;
	}

	public void measurementsChanged() {
		setChanged();//必须调用这个方法，指示状态已改变
		notifyObservers();
	}

	public void setMeasurements(float temperature, float huidity, float pressure) {
		this.temperature = temperature;
		this.humidity = huidity;
		this.pressure = pressure;
		measurementsChanged();
	}
}
